home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / a_to_d / 123demo / unit123.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  26.3 KB  |  671 lines

  1. (*  Written by Dan Glanz, Alexandria, Virginia (76672,2572), May, 1989. *)
  2. (*  as a public service.                                                *)
  3. (*  There are no restrictions on use and no gaurantees that it works.   *)
  4.  
  5. (*    All I ask is a smidgeon of credit.                          *)
  6. (*  If you include this in a program, leave the credit line in. *)
  7. (*  If you modify the unit, add your own credit line.           *)
  8.  
  9. (*    This is a Turbo Pascal 5.0 unit designed to allow reading and writing
  10.     of Lotus 1-2-3,    Symphony, VP-Planner and other such files using the
  11.     Lotus 1-2-3    file format.
  12.  
  13.               ************** update information  ***************
  14.  
  15.     This version is updated to allow reading and writing of range names and
  16.     extents and column widths.  The structure of the "Lotus_Record_Type" has
  17.     been modified to variant records for efficiency in data storage.
  18.  
  19.               **************************************************
  20.  
  21.     Lotus 1-2-3 uses 8 byte reals (TP's double's).  Any program using
  22.     Lotus 1-2-3 data must either use a math coprocessor {$N+} or
  23.     coprocessor emulation {$N+,E+}
  24.  
  25.     For demonstration purposes, a separate program called TEST123
  26.     is included in the ARC file.
  27.  
  28.     It reads any Lotus format file and copies out label, integer, real
  29.     column width, range identification and the current value of formula cells
  30.     to a file in the same directory with the same name but with an extension
  31.     of '.WK!'  It does not copy formulas and other such information.
  32.     It is primarily designed to allow access to the DATA.  However, it
  33.     does read column widths, and range names and extents.
  34.  
  35.     Take note that Lotus rows and columns are numbered starting with 0.
  36.     that is Column A is 0 and Row 1 is 0.
  37.  
  38.     Lotus_Version is set up as a typed constant as if the file were
  39.     a Lotus version 1.0 or 1a type file.  Change it if you need to.
  40.     The program automatically writes a version record at the beginning of
  41.     the file when the file is opened for writing by calling
  42.     Open_Lotus_Write_File.  It must do this or Lotus 1-2-3 will not
  43.     allow use of the file.  If you have used Open_Lotus_Read_File to open
  44.     a file to be copied or accessed, then the version of that file is
  45.     substituted for the default Lotus_Version.
  46.  
  47.     If you want to use the unit to create a Lotus formatted file directly,
  48.     you must provide the row and column of the data in Lotus.Row and
  49.     Lotus.Column (starting with row 0 and column 0), define the format
  50.     in Lotus.Format (default seems to be 255) set the value in either
  51.     Lotus.Integer_Value, Lotus.Real_Value, Lotus.Column_Width, or
  52.     Lotus.Range_Name, Range_Start Column, etc., or Lotus.Label_Value.
  53.     Then set Lotus.Cell_Type := to Integer_Type, Real_Type, Column_Width_Type,
  54.     RAnge_Type or Label_Type as the case may be    and call Write_Lotus_Record.
  55.  
  56.     Note: When you write your own labels in Label_Value, make sure you put
  57.     a ' or " or ^ as the first character of the string.  Also, you may be
  58.     able to include formulas in a worksheet you are creating by writing out
  59.     a label cell containing with the formula and then deleting
  60.     the ', ", or ^ in the spreadsheet itself, perhaps by using a macro.
  61.  
  62.     When you call Close_Lotus_Write_File, an end of file record is written
  63.     and the file is automatically closed.
  64.  
  65.     Lotus 1-2-3 is a trademark of Lotus Corporation.
  66.  
  67. *) {That's the End of Dan's original comments}
  68.  
  69. {*****************************************************}
  70. {*                                                   *}
  71. {* Updated by RGMinutillo to serve as a Delphi unit  *}
  72. {* July 1, 1995                                      *}
  73. {*                                                   *}
  74. {*****************************************************}
  75.  
  76. {
  77.  
  78.   I cleaned out the CRT routines for displaying the cells, and the
  79.   file name routines. I also provide a different demo file.
  80.  
  81.   I've kept the Dan Glanz' concept of the all inclusive record-type, but
  82.   the unit could also have been 'parameterized' by making each routine
  83.   expect parameters which matched the specific structure of each 123 record
  84.   type. I also could have added error/range checking, but that would be
  85.   too much like work. I have added some elements to the Lotus record type
  86.   definition to allow for some more 123 record types: specifically, I have
  87.   added:
  88.  
  89.     PrintRange
  90.     PrintSetupString
  91.     PrintMargins
  92.     GlobalProtection (byte: 0 for off and 1 for on)
  93.     ActiveRange
  94.  
  95.     .
  96.   I needed those to reproduce a VB program I've been converting. Lotus
  97.   published all of the record types and record formats for the original
  98.   WK1 and Symphony format, so it's reasonably easy to add some of the
  99.   more exotic WK1 records like Query Range, Data Range, etc. Parsing
  100.   formulae remains a challenge, however, since they are tokenized. If it's
  101.   a simple formula with relative cell references, create it in a spreadsheet,
  102.   then read it and capture the string of tokens, and hard code it. (Ugh!,
  103.   but see demo.) Another problem with tokenized formulae is that they can
  104.   exceed the 512 byte length this unit expects.
  105.  
  106.   Some useful Lotus.Format bytes values are
  107.        128-143: protected fixed 0 tp 15 decimal places
  108.        144-159: protected scientific 0 to 15 decimal places
  109.        160-175: protected currency 0 t 15 decimal places
  110.        176-191: protected decimal 0 to 15 decimal places
  111.        192-207: protected comma 0 to 15 decimal places
  112.                 subtract 128 for unprotected
  113.  
  114.   Although elegant in many ways, this is a very crude implementation by
  115.   OOPS standards, since it is not 'object'ified in any way. Still, it
  116.   does basic WK1 reading and writing, which was what I was looking for.
  117.   Thanks Dan.
  118.  
  119.   I've also included the TEST123P project, with the DEMO123 Unit, which
  120.   reads and displays WK1 files, shows how to thoroughly de-code the
  121.   Lotus.format byte, and writes a demo file.}
  122.  
  123. Unit Unit123;
  124. Interface
  125.  
  126. uses Dialogs;
  127.  
  128. Const
  129.     Lotus_Version : integer = 1028;  {1028 for Lotus 1}
  130.                                      {1029 for Symphony 1.0}
  131.                                      {1030 for Lotus 2 & Symphony 1.1}
  132.  
  133. Type
  134. Lotus_Cell_Type = (Version_Type, End_Of_File_Type, Blank_Type,
  135.                    Integer_Type, Real_Type, Label_Type,
  136.                    Formula_Type, Unidentified_Type, Range_Type,
  137.                    Column_Width_Type, Protection_Type,
  138.                    ARange_Type, PRange_Type, Print_Setup_Type, PMargins_Type);
  139.  
  140. Lotus_Record_Type =
  141.  Record
  142.  Cell_Type_Code     : Integer;
  143.  Cell_Length     : Integer;
  144.  Format          : Byte;
  145.  Column          : integer;
  146.  Row             : integer;
  147.  Cell_Type       : Lotus_Cell_Type;
  148.  Alpha_Column    : String[8];
  149.  case integer of
  150.       6:   (ARange_Start_Column : integer;
  151.             ARange_Start_Row    : integer;
  152.             ARange_End_Column   : integer;
  153.             ARange_End_Row      : integer;
  154.             Alpha_ARange_Start  : string;
  155.             Alpha_ARange_End    : String);
  156.       8:   (Column_Width        : Byte);
  157.       11:  (Range_Name          : string[16];
  158.             Range_Start_Column  : integer;
  159.             Range_Start_Row     : integer;
  160.             Range_End_Column    : integer;
  161.             Range_End_Row       : integer;
  162.             Alpha_Range_Start   : string;
  163.             Alpha_Range_End     : String);
  164.       13:  (Integer_Value       : integer);
  165.       14:  (Real_Value          : double);
  166.       15:  (Label_Value         : string;
  167.             Zero: byte);
  168.       16:  (Formula_Value       : double;
  169.             Formula_Length      : integer;
  170.             Formula             : array [0 .. 255] of byte);
  171.       26:  (PRange_Start_Column : integer;
  172.             PRange_Start_Row    : integer;
  173.             PRange_End_Column   : integer;
  174.             PRange_End_Row      : integer;
  175.             Alpha_PRange_Start  : string;
  176.             Alpha_PRange_End    : String);
  177.       36:  (Protection_Value    : Byte);
  178.       39:  (Print_Setup_Value   : string[40]);
  179.       40:  (PMargins_left       : integer;
  180.             PMargins_Right      : integer;
  181.             PMargins_Page_Lines : integer;
  182.             PMargins_Top        : integer;
  183.             PMargins_Bottom     : integer);
  184.       255: (Unidentified        : array [0 .. 511] of byte);
  185.       end; {case}
  186. var
  187.     Lotus_Read_File_Name    : String;
  188.     Lotus_Read_File         : file;
  189.     Lotus_Write_File_Name   : String;
  190.     Lotus_Write_File        : file;
  191.     Lotus_End_Of_File       : boolean;
  192.     Lotus_Version_Name        : string;
  193.     Lotus                   : Lotus_Record_Type;
  194.  
  195. Procedure Open_Lotus_Read_File;
  196. Procedure Get_Version_Name;
  197. Procedure Get_Alpha_Column(var Alpha_Column_ID : String; Column_Number, Row_Number:integer);
  198. Procedure Read_Type_and_Length;
  199. Procedure Read_Format_Info;
  200. Procedure Read_Lotus_Record;
  201. Procedure Close_Lotus_Read_File;
  202. Procedure Open_Lotus_Write_File;
  203. Procedure Write_Type_and_Length;
  204. Procedure Write_Format_Info;
  205. Procedure Write_Lotus_Record;
  206. Procedure Close_Lotus_Write_File;
  207.  
  208. implementation
  209.  
  210. (****************************************************************)
  211. (****************************************************************)
  212.  
  213. Procedure Read_Type_and_Length;    {Could be changed to a single }
  214.                                    {BlockRead since Cell_Type_Code}
  215.                                    {Cell_Length are adjacent in the record}
  216.                                    {definition and on the file.}
  217. begin
  218.     BlockRead(Lotus_Read_File, Lotus.Cell_Type_Code, 2);
  219.     BlockRead(Lotus_Read_File, Lotus.Cell_Length,    2);
  220. end;
  221.  
  222. (****************************************************************)
  223.  
  224. Procedure Write_Type_and_Length;        {Could be changed to a single }
  225.                                         {BlockWrite since format, column}
  226.                                         {and row are adjacent in the record}
  227.                                         {definition and on the file.}
  228. begin
  229.     BlockWrite(Lotus_Write_File, Lotus.Cell_Type_Code, 2);
  230.     BlockWrite(Lotus_Write_File, Lotus.Cell_Length,    2);
  231. end;
  232.  
  233. (****************************************************************)
  234.  
  235. Procedure Get_Alpha_Column(var Alpha_Column_ID : String; Column_Number, Row_Number:integer);
  236. Var
  237.    First_Char : char;
  238.    Second_Char : char;
  239.    Row_String  : string[6];
  240. Begin
  241.    First_Char := char(64 + Column_Number div 26);
  242.    Second_Char := char(65 + Column_Number -((byte(First_Char)-64) * 26));
  243.    If First_Char = #64 then First_Char := #32;
  244.    Str(Row_Number + 1, Row_String);
  245.    Alpha_Column_ID := First_Char + Second_Char + Row_String;
  246. end;
  247.  
  248.  
  249. (****************************************************************)
  250.  
  251. Procedure Read_Format_Info;             {Could be changed to a single }
  252.                                         {BlockRead since format, column}
  253.                                         {and row are adjacent in the record}
  254.                                         {definition and on the file.}
  255. Var
  256.     Alpha_Column_ID : string;
  257.  
  258. begin
  259.     BlockRead(Lotus_Read_File, Lotus.Format, 1);
  260.     BlockRead(Lotus_Read_File, Lotus.Column, 2);
  261.     BlockRead(Lotus_Read_File, Lotus.Row,    2);
  262.  
  263.     Get_Alpha_Column(Alpha_Column_ID, Lotus.Column, Lotus.Row);
  264.     Lotus.Alpha_Column := Alpha_Column_ID;
  265.  
  266. end;
  267.  
  268. (****************************************************************)
  269.  
  270. Procedure Write_Format_Info;            {Could be changed to a single }
  271.                                         {BlockWrite since format, column}
  272.                                         {and row are adjacent in the record}
  273.                                         {definition and on the file.}
  274. begin
  275.     BlockWrite(Lotus_Write_File, Lotus.Format, 1);
  276.     BlockWrite(Lotus_Write_File, Lotus.Column, 2);
  277.     BlockWrite(Lotus_Write_File, Lotus.Row,    2);
  278. end;
  279.  
  280. (****************************************************************)
  281.  
  282. Procedure Open_Lotus_Read_File;
  283. begin
  284. {$I-}
  285.     Assign(Lotus_Read_File,Lotus_Read_File_Name);
  286.     Reset(Lotus_Read_File,1);
  287.     If IoResult <> 0 then
  288.         begin
  289.             ShowMessage('Error opening file ');
  290.         end;
  291. {$I+}
  292.     Read_Lotus_Record;                      {Read the first record}
  293.                                             {If the first record is}
  294.                                             {not a Version_Type record}
  295.                                             {then this is not a Lotus File}
  296.     If Lotus.Cell_Type <> Version_Type then
  297.        begin
  298.             ShowMessage('This is not a Lotus File');
  299.        end;
  300.        Lotus_End_Of_File := false;
  301. end;
  302.  
  303. (****************************************************************)
  304.  
  305. Procedure Open_Lotus_Write_File;
  306. begin
  307. {$I-}
  308.     Assign(Lotus_Write_File,Lotus_Write_File_Name);
  309.     ReWrite(Lotus_Write_File,1);
  310.     If IoResult <> 0 then
  311.         begin
  312.             ShowMessage('Error opening file '+ Lotus_Write_File_Name);
  313.         end;
  314. {$I+}
  315.  
  316. { Automatically write a version type record at the beginning of the file }
  317. { Lotus_Version is a typed constant set to Version 1.0 or 1A by default  }
  318. { If you have used Open_Lotus_File to read another Lotus file, then it   }
  319. { will have already read the version type record from the input file     }
  320.  
  321.     Lotus.Cell_Type_Code := 0;
  322.     Lotus.Cell_Length    := 2;
  323.     Write_Type_and_Length;
  324.     BlockWrite(Lotus_Write_File,Lotus_Version,2);
  325.  
  326. end;
  327.  
  328. (****************************************************************)
  329.  
  330. Procedure Close_Lotus_Read_File;
  331. begin
  332.     Close(Lotus_Read_File);
  333. end;
  334.  
  335. (****************************************************************)
  336.  
  337. Procedure Close_Lotus_Write_File;
  338. begin
  339. { Write an end of file record at the end of the file }
  340.     Lotus.Cell_Type_Code := 1;
  341.     Lotus.Cell_Length    := 0;
  342.     Write_Type_and_Length;            {End the file with a type 1 record}
  343.     Close(Lotus_Write_File);
  344. end;
  345.  
  346. (****************************************************************)
  347.  
  348. Procedure Get_Version_Name;
  349. begin
  350.     Case Lotus_Version of
  351.         1028:
  352.             Lotus_Version_Name := 'Lotus 1-2-3 Version 1.0 or 1A';
  353.         1029:
  354.             Lotus_Version_Name := 'Symphony Version 1.0';
  355.         1030:
  356.             Lotus_Version_Name := 'Lotus 1-2-3 Version 2.0, 2.1 or Symphony Version 1.1';
  357.         Else
  358.             Lotus_Version_Name := 'Unidentified';
  359.     end;
  360. end;
  361.  
  362. (****************************************************************)
  363.  
  364. Procedure Read_Lotus_Record;
  365.  
  366. var
  367.     Alpha_Column_ID : string;
  368.  
  369. begin
  370.     FillChar(Lotus, SizeOf(Lotus), #0);
  371.     Read_Type_and_Length;
  372.           Case Lotus.Cell_Type_Code of
  373.               0:  begin  {Version Record}
  374.                     Lotus.Cell_Type := Version_Type;
  375.             BlockRead(Lotus_Read_File, Lotus_Version, 2);
  376.             Get_Version_Name;
  377.             end;
  378.  
  379.                 1:  begin  {End of File}
  380.                     Lotus.Cell_Type := End_Of_File_Type;
  381.                     Lotus_End_of_File := True;
  382.             end;
  383.  
  384.                 6: begin  {Active Range definition}
  385.                     Lotus.Cell_Type := ARange_Type;
  386.                     BlockRead(Lotus_Read_File, Lotus.ARange_Start_Column,2);
  387.                     BlockRead(Lotus_Read_File, Lotus.ARange_Start_Row,2);
  388.                     BlockRead(Lotus_Read_File, Lotus.ARange_End_Column,2);
  389.                     BlockRead(Lotus_Read_File, Lotus.ARange_End_Row,2);
  390.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.ARange_Start_Column,
  391.                        Lotus.ARange_Start_Row);
  392.                     Lotus.Alpha_ARange_Start := Alpha_Column_ID;
  393.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.ARange_End_Column,
  394.                        Lotus.ARange_End_Row);
  395.                     Lotus.Alpha_ARange_End := Alpha_Column_ID;
  396.                     end;
  397.  
  398.                 8:  begin  {Column width type}
  399.                     Lotus.Cell_Type := Column_Width_Type;
  400.             BlockRead(Lotus_Read_File, Lotus.Column, 2);
  401.             BlockRead(Lotus_Read_File, Lotus.Column_Width,1);
  402.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.Column, 0);
  403.                     Lotus.Alpha_Column := Alpha_Column_ID;
  404.                     end;
  405.  
  406.                 11: begin  {Range Name definition}
  407.                     Lotus.Cell_Type := Range_Type;
  408.                     BlockRead(Lotus_Read_File, Lotus.Range_Name[1],16);
  409.                     Lotus.Range_Name[0] := Char(16);
  410.                     BlockRead(Lotus_Read_File, Lotus.Range_Start_Column,2);
  411.                     BlockRead(Lotus_Read_File, Lotus.Range_Start_Row,2);
  412.                     BlockRead(Lotus_Read_File, Lotus.Range_End_Column,2);
  413.                     BlockRead(Lotus_Read_File, Lotus.Range_End_Row,2);
  414.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.Range_Start_Column,
  415.                        Lotus.Range_Start_Row);
  416.                     Lotus.Alpha_Range_Start := Alpha_Column_ID;
  417.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.Range_End_Column,
  418.                        Lotus.Range_End_Row);
  419.                     Lotus.Alpha_Range_End := Alpha_Column_ID;
  420.                     end;
  421.  
  422.         12: begin  {Blank Record}
  423.             Lotus.Cell_Type := Blank_Type;
  424.             Read_Format_Info;
  425.             end;
  426.  
  427.                 13: begin  {Integer}
  428.             Lotus.Cell_Type := Integer_Type;
  429.             Read_Format_Info;
  430.             BlockRead(Lotus_Read_File, Lotus.Integer_Value, 2);
  431.             end;
  432.  
  433.         14: begin  {Real Value}
  434.             Lotus.Cell_Type := Real_Type;
  435.             Read_Format_Info;
  436.             BlockRead(Lotus_Read_File, Lotus.Real_Value, 8);
  437.             end;
  438.  
  439.         15: begin  {Label}
  440.             Lotus.Cell_Type := Label_Type;
  441.             Read_Format_Info;
  442.                     If Lotus.Cell_Length > 261 then
  443.                        begin
  444.                        ShowMessage('Big problem! Label at has length > 255');
  445.                        end;
  446.             BlockRead(Lotus_Read_File, Lotus.Formula, Lotus.Formula_Length);
  447.             BlockRead(Lotus_Read_File, Lotus.Label_Value[1], Lotus.Cell_Length - 6);
  448.             Lotus.Label_Value[0] := char(Lotus.Cell_Length - 6);
  449.             BlockRead(Lotus_Read_File, Lotus.Zero, 1);
  450.             end;
  451.  
  452.         16: begin  {Formula}
  453.             Lotus.Cell_Type := Formula_Type;
  454.             Read_Format_Info;
  455.             BlockRead(Lotus_Read_File, Lotus.Formula_Value, 8);
  456.             BlockRead(Lotus_Read_File, Lotus.Formula_Length, 2);
  457.                     If Lotus.Formula_Length > 255 then
  458.                        begin
  459.                        ShowMessage('Big problem! Formula cell  has length > 255');
  460.                        end;
  461.             BlockRead(Lotus_Read_File, Lotus.Formula, Lotus.Formula_Length);
  462.             end;
  463.  
  464.                 26: begin  {Print Range definition}
  465.                     Lotus.Cell_Type := PRange_Type;
  466.                     BlockRead(Lotus_Read_File, Lotus.PRange_Start_Column,2);
  467.                     BlockRead(Lotus_Read_File, Lotus.PRange_Start_Row,2);
  468.                     BlockRead(Lotus_Read_File, Lotus.PRange_End_Column,2);
  469.                     BlockRead(Lotus_Read_File, Lotus.PRange_End_Row,2);
  470.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.PRange_Start_Column,
  471.                        Lotus.PRange_Start_Row);
  472.                     Lotus.Alpha_PRange_Start := Alpha_Column_ID;
  473.                     Get_Alpha_Column(Alpha_Column_ID, Lotus.PRange_End_Column,
  474.                        Lotus.PRange_End_Row);
  475.                     Lotus.Alpha_PRange_End := Alpha_Column_ID;
  476.                     end;
  477.  
  478.         36: begin  {Global Protection Value}
  479.             Lotus.Cell_Type := Protection_Type;
  480.                     BlockRead(Lotus_Read_File, Lotus.Protection_Value, 1);
  481.             end;
  482.  
  483.         39: begin  {Print Setup String}
  484.             Lotus.Cell_Type := Print_Setup_Type;
  485.                     BlockRead(Lotus_Read_File, Lotus.Print_Setup_Value, 40);
  486.             end;
  487.  
  488.         40: begin  {Print Margins}
  489.             Lotus.Cell_Type := PMargins_Type;
  490.                     BlockRead(Lotus_Read_File, Lotus.PMargins_Left, 2);
  491.                     BlockRead(Lotus_Read_File, Lotus.PMargins_Right, 2);
  492.                     BlockRead(Lotus_Read_File, Lotus.PMargins_Page_Lines, 2);
  493.                     BlockRead(Lotus_Read_File, Lotus.PMargins_Top, 2);
  494.                     BlockRead(Lotus_Read_File, Lotus.PMargins_Bottom, 2);
  495.             end;
  496.  
  497.  
  498.                 Else       {Unidentified}
  499.             begin
  500.             Lotus.Cell_Type := Unidentified_Type;
  501.  
  502.             {    Use the following line only if you are sure that the length }
  503.             {    of the unidentified data type is less than 512 characters.  }
  504.             {    I the unidentified data cell is more than 512 byte long,    }
  505.             {    it could cream the program by overwriting code.             }
  506.             {    The check on cell length protects against this. But,        }
  507.             {    if you don't know the maximum cell length, the safest       }
  508.             {    approach is the approach I have taken, just skip the        }
  509.             {    unknown data cell                                           }
  510.             {                                                                }
  511.             {    If Lotus.Cell_Length > 512 then                             }
  512.             {        begin                                                   }
  513.             {           Writeln('Big problem! Cell at row ', Lotus.Row, ' Column ', Lotus.Coulmn, ' has  length > 512');   }
  514.             {           Halt;                                                }
  515.             {        end;                                                    }
  516.             {                                                                }
  517.             {    BlockRead (Lotus_Read_File, Lotus.Unidentified , Lotus.Cell_Length);}
  518.  
  519.  
  520.             {    This is the safest way.}
  521.  
  522.             Seek(Lotus_Read_File, FilePos(Lotus_Read_File) + Lotus.Cell_Length);
  523.  
  524.             end;
  525.             end; {CASE}
  526. end;  {PROC}
  527.  
  528. (****************************************************************)
  529.  
  530. (****************************************************************)
  531.  
  532. Procedure Write_Lotus_Record;
  533.  
  534. begin
  535.     Case Lotus.Cell_Type of
  536.  
  537.         Column_Width_Type:
  538.             begin
  539.                 Lotus.Cell_Type_Code := 8;
  540.                 Lotus.Cell_Length := 3;
  541.                 Write_Type_and_Length;
  542.                 BlockWrite(Lotus_Write_File , Lotus.Column, 2);
  543.                 BlockWrite(Lotus_Write_File , Lotus.Column_Width, 1);
  544.             end;
  545.  
  546.         Range_Type:
  547.             begin
  548.                 Lotus.Cell_Type_Code := 11;
  549.                 Lotus.Cell_Length := 24;
  550.                 Write_Type_and_Length;
  551.                 BlockWrite(Lotus_Write_File,Lotus.Range_Name[1], 16);
  552.                 BlockWrite(Lotus_Write_File,Lotus.Range_Start_Column,2);
  553.                 BlockWrite(Lotus_Write_File,Lotus.Range_Start_Row,2);
  554.                 BlockWrite(Lotus_Write_File,Lotus.Range_End_Column,2);
  555.                 BlockWrite(Lotus_Write_File,Lotus.Range_End_Row,2);
  556.             end;
  557.  
  558.         PRange_Type:
  559.             begin
  560.                 Lotus.Cell_Type_Code := 26;
  561.                 Lotus.Cell_Length := 8;
  562.                 Write_Type_and_Length;
  563.                 BlockWrite(Lotus_Write_File,Lotus.PRange_Start_Column,2);
  564.                 BlockWrite(Lotus_Write_File,Lotus.PRange_Start_Row,2);
  565.                 BlockWrite(Lotus_Write_File,Lotus.PRange_End_Column,2);
  566.                 BlockWrite(Lotus_Write_File,Lotus.PRange_End_Row,2);
  567.             end;
  568.  
  569.         ARange_Type:
  570.             begin
  571.                 Lotus.Cell_Type_Code := 6;
  572.                 Lotus.Cell_Length := 8;
  573.                 Write_Type_and_Length;
  574.                 BlockWrite(Lotus_Write_File,Lotus.ARange_Start_Column,2);
  575.                 BlockWrite(Lotus_Write_File,Lotus.ARange_Start_Row,2);
  576.                 BlockWrite(Lotus_Write_File,Lotus.ARange_End_Column,2);
  577.                 BlockWrite(Lotus_Write_File,Lotus.ARange_End_Row,2);
  578.             end;
  579.  
  580.         Blank_Type:
  581.             Exit;
  582.  
  583.     Integer_Type:
  584.         begin
  585.              Lotus.Cell_Type_Code := 13;
  586.          Lotus.Cell_Length := 7;
  587.          Write_Type_and_Length;
  588.          Write_Format_Info;
  589.          BlockWrite(Lotus_Write_File,Lotus.Integer_Value,2);
  590.          end;
  591.  
  592.         Real_Type:
  593.         begin
  594.         Lotus.Cell_Type_Code := 14;
  595.         Lotus.Cell_Length := 13;
  596.         Write_Type_and_Length;
  597.         Write_Format_Info;
  598.         BlockWrite(Lotus_Write_File,Lotus.Real_Value,8);
  599.         end;
  600.  
  601.         Label_Type:
  602.         begin
  603.         Lotus.Cell_Type_Code := 15;
  604.             lotus.Cell_Length := 6 + Length(Lotus.Label_Value);
  605.           Lotus.Zero := 0;
  606.           Write_Type_and_Length;
  607.           Write_Format_Info;
  608.           BlockWrite(Lotus_Write_File,Lotus.Label_Value[1],Length(Lotus.Label_Value));
  609.           BlockWrite(Lotus_Write_File,Lotus.Zero, 1);
  610.             end;
  611.  
  612.         Formula_Type:    {NOTE: ONLY COPIES OUT THE CURRENT VALUE AS A REAL}
  613.                          { If you want to copy the formula then also       }
  614.                          { BlockWrite Lotus.Formula_Value.                 }
  615.                          { See Read_Lotus_File for how to interpret length }
  616.                          { Also, you must change the Cell_Type_Code to 16  }
  617.          {begin
  618.              Lotus.Cell_Type_Code := 14;
  619.              Lotus.Cell_Length := 13;
  620.              Write_Type_and_Length;
  621.              Write_Format_Info;
  622.              BlockWrite(Lotus_Write_File,Lotus.Formula_Value,8);
  623.              end;}
  624.  
  625.               {This version writes a true formula cell}
  626.                begin
  627.              Lotus.Cell_Type_Code := 16;
  628.              Lotus.Cell_Length := 15+Lotus.Formula_Length;
  629.              Write_Type_and_Length;
  630.              Write_Format_Info;
  631.              BlockWrite(Lotus_Write_File,Lotus.Formula_Value,8);
  632.              BlockWrite(Lotus_Write_File,Lotus.Formula_Length,2);
  633.              BlockWrite(Lotus_Write_File,Lotus.Formula,Lotus.Formula_Length);
  634.              end;
  635.  
  636.  
  637.     Protection_Type: begin {Global Protection Value}
  638.                 Lotus.Cell_Type_Code := 36;
  639.                 Lotus.Cell_Length := 1;
  640.                 Write_Type_and_Length;
  641.                 BlockWrite(Lotus_Write_File, Lotus.Protection_Value, 1);
  642.         end;
  643.  
  644.     Print_Setup_Type: begin  {Printer Setup String}
  645.                 Lotus.Cell_Type_Code := 39;
  646.                 Lotus.Cell_Length := 40;
  647.                 Write_Type_and_Length;
  648.                 BlockWrite(Lotus_Write_File, Lotus.Print_Setup_Value, 40);
  649.         end;
  650.  
  651.     PMargins_Type: begin    {Print Margins String}
  652.                 Lotus.Cell_Type_Code := 40;
  653.                 Lotus.Cell_Length := 10;
  654.                 Write_Type_and_Length;
  655.                 BlockWrite(Lotus_Write_File, Lotus.PMargins_Left, 2);
  656.                 BlockWrite(Lotus_Write_File, Lotus.PMargins_Right, 2);
  657.                 BlockWrite(Lotus_Write_File, Lotus.PMargins_Page_Lines,2);
  658.                 BlockWrite(Lotus_Write_File, Lotus.PMargins_Top, 2);
  659.                 BlockWrite(Lotus_Write_File, Lotus.PMargins_Bottom, 2);
  660.         end;
  661.  
  662.      Else
  663.             begin
  664.          end;
  665.      end; {CASE}
  666. end; {PROC}
  667.  
  668. (****************************************************************)
  669.  
  670. end.
  671.